<?php
//自定义标签库
class TagLibHd extends TagLib
{
	protected $tags=array(
		
		'hdjs'=>array('attr'=>'jquery','close'=>0),
		'bootstrap'=>array('attr'=>'','close'=>0)
	);
	public function _bootstrap($attr,$content)
	{
		$php =<<<str
			<link href='__ROOT__/Data/Org/bootstrap/css/bootstrap.min.css' rel='stylesheet' media='screen'>
			<script src='__ROOT__/Data/Org/bootstrap/js/bootstrap.min.js'></script>
			<!--[if lte IE 6]>
			<link rel="stylesheet" type="text/css" href="__ROOT__/Data/Org/bootstrap/ie6/css/bootstrap-ie6.css">
			<![endif]-->
			<!--[if lt IE 9]>
			<script src="__ROOT__/Data/Org/bootstrap/js/html5shiv.min.js"></script>
			<script src="__ROOT__/Data/Org/bootstrap/js/respond.min.js"></script>
			<![endif]-->

str;
		return $php;
	}


	/**
	 * [_hdjs 使用hdjs]
	 * @param  [type] $attr    [description]
	 * @param  [type] $content [description]
	 * @return [type]          [description]
	 */
	public function _hdjs($attr,$content)
	{
		if($attr)
			$attr = $this->parseXmlAttr($attr,'hdjs');
		$jquery = isset($attr['jquery'])?$jquery:true;
		if($jquery)
		$php="<script type='text/javascript' src='__ROOT__/Data/Org/Jquery/jquery-1.8.2.min.js'></script>\n";
	$php .=<<<str
	<link href='__ROOT__/Data/Org/hdjs/hdjs.css' rel='stylesheet' media='screen'>
	<script type='text/javascript' src='__ROOT__/Data/Org/hdjs/hdjs.min.js'></script>
	<script type='text/javascript' src='__ROOT__/Data/Org/hdjs/org/cal/lhgcalendar.min.js'></script>
	<script type='text/javascript'>
		ACTION='__URL__'; //当前模块(控制器)
		ROOT='__ROOT__'; //当前项目根路径
		PUBLIC= '__PUBLIC__';//当前定义的Public目录
	</script>
str;
		return $php;
	}

	/**
	 * [_keditor 编辑器kindeditor]
	 * @param  [type] $attr    [description]
	 * @param  [type] $content [description]
	 * @return [type]          [description]
	 */
	public function _keditor($attr,$content)
	{
		if($attr)
			$attr=$this->parseXmlAttr($attr,'keditor');
		$name=isset($attr['name'])?$attr['name']:'';
		$content=isset($attr['content'])?$attr['content']:'';
		$str='';
		if (!defined("DJ_KEDITOR")) 
		{
			$str .="<script type='text/javascript' src='".__ROOT__."/Data/Org/Keditor/kindeditor-all-min.js'></script>
			";
			define("DJ_KEDITOR", true);
		}
		$str .=<<<php
			<script type="text/javascript">
			var optionVar ='{$name}'
			KindEditor.ready(function(K) {
					var optionVar= "editor"+optionVar;
					optionVar = K.create('#{$name}', {
						//cssPath : '../plugins/code/prettify.css',
						uploadJson : '__ROOT__/Data/Org/Keditor/php/upload_json.php',
						fileManagerJson : '__ROOT__/Data/Org/Keditor/php/file_manager_json.php',
						width:'99%',
						height:'300px',
						allowFileManager : true,
						afterCreate : function() {
							var self = this;
							K.ctrl(document, 13, function() {
								self.sync();
								K('form[name=example]')[0].submit();
							});
							K.ctrl(self.edit.doc, 13, function() {
								self.sync();
								K('form[name=example]')[0].submit();
							});
						},
						//langType:'en',
						afterBlur: function(){this.sync();}
				});
			});
			</script>
			<textarea name="{$name}" id="{$name}" >{$content}</textarea>
php;
	return $str;
	}
}
?>